<?php
    class menu_index_controller extends controllerBase
    {
        public function process()
        {
            if(isset($_POST['val']))
            {
                $aVals = $_POST['val'];
                if(isset($aVals['id']) && count($aVals['id']))
                {
                    foreach($aVals['id'] as $iMenuId)
                    {
                        if($iMenuId)
                        {
                            $this->database->delete('menus','menu_id = '.(int)$iMenuId);
                        }
                    }
                    return $this->url->getLink('admin/menu',true,'Delete menus successful.');
                }
            }
            $aMenus = $this->database->getListObject('SELECT menus.*, m1.title AS parent_menu_name FROM menus LEFT JOIN menus as m1 ON menus.parent_menu_id = m1.menu_id');
            $this->set(array('aMenus' => $aMenus));
        }
    }
?>
